home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
giochi
/
chinacha.lha
/
ChinaChallenge3
/
C
/
cc3.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-08
|
8KB
|
296 lines
/************************************************************************
* *
* Header File for China Challenge III - the C Version *
* *
* author : Gunther Nikl *
* created : 8-may-94 *
* last change : 8-may-94 *
* *
*************************************************************************/
#ifndef _CC3_H
#define _CC3_H
/* all includes */
#include <exec/memory.h>
#include <dos/dosextens.h>
#include <devices/audio.h>
#include <hardware/cia.h>
#include <graphics/gfx.h>
#include <graphics/rastport.h>
#include <intuition/screens.h>
#include <intuition/intuition.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/alib.h>
#include <proto/exec.h>
#include <proto/dos.h>
LONG sprintf(STRPTR buffer, STRPTR fmt, ...);
/* own function prototypes */
VOID InitMusic();
LONG MakeGfx();
VOID CloseGfx();
VOID FreeMusic();
VOID DoIDCMP(ULONG imClass, ULONG imCode);
VOID ProjectAbout();
VOID ProjectQuit();
VOID OptNewGame();
VOID OptUndoMove();
VOID OptUndoAll();
VOID OptLoadDragon();
VOID OptSaveDragon();
VOID OptMusic();
LONG CheckPos();
VOID MakeDragon();
LONG Random(ULONG);
VOID ShowDragon();
VOID PrintPieces();
BPTR ReqFile(LONG);
VOID ChangeFunc();
/* useful structure definition */
struct About
{
UBYTE pens[2],x,y,text[24];
};
struct Undo
{
UWORD pos1,pos2;
};
struct Dragon
{
struct Undo UndoTable[60];
BYTE PieceTable[288];
};
/* gfx stuff */
#define DEPTH 3L
#define WIDTH 320L
#define HEIGHT 200L
#define MAXCOUNT 120L
#define SAMPLESIZE 104072L
#define ciaa (*((struct CIA*)0xbfe001L))
UBYTE ArpName[] = "arp.library";
UBYTE AudioName[] = "audio.device";
UBYTE TopazName[] = "topaz.font";
UBYTE SampleName[] = "Sample";
UBYTE PieceFmt[] = "%3ld";
UBYTE BlankStr[] = " ";
UBYTE AboutStr[] = "About";
UBYTE QuitStr[] = "Quit";
UBYTE NewGameStr[] = "New game";
UBYTE UndoMoveStr[] = "Undo last move";
UBYTE UndoAllStr[] = "Undo all moves";
UBYTE LoadDragonStr[] = "Load Dragon";
UBYTE SaveDragonStr[] = "Save Dragon";
UBYTE PlayMusicStr[] = "Play Music";
UBYTE OptionsStr[] = "Options";
UBYTE ProjectStr[] = "Project";
struct About About[] =
{ { {4,0},9, 9," China Challenge III " },
{ {4,0},9, 16," ------------------- " },
{ {4,0},9, 29," written 1991 by " },
{ {2,0},9, 44," Dirk Hoffmann " },
{ {4,0},6, 60," rewritten 1993 by " },
{ {2,0},9, 75," Gunther Nikl " },
{ {3,0},9, 89,"This game is Freeware !" },
{ {3,0},9, 99," Enjoy ... " },
{ {2,0},9,112," (dedicated to Astrid) " } };
UBYTE Version[] = "$VER: China Challenge III 1.0a (8.5.94)";
#define Title (Version+6)
struct TextAttr TopazFont =
{ TopazName,8,FS_NORMAL,FPF_ROMFONT };
struct NewScreen NewScreen =
{ 0,0, WIDTH,HEIGHT, DEPTH, 4,2, 0 /* LORES */,
SCREENQUIET | SCREENBEHIND | CUSTOMSCREEN, &TopazFont, Title, NULL, NULL };
UWORD ColorTab[] =
{ 0x000,0xfeb,0xfe9,0xcb7,0xa43,0xc52,0x4a0,0x86b };
struct NewWindow NewWindow =
{ 0,1, WIDTH,HEIGHT-2, 2,4,
MENUPICK | MOUSEBUTTONS, ACTIVATE | BORDERLESS | BACKDROP,
NULL,NULL,NULL,NULL,NULL,
WIDTH,HEIGHT-2, WIDTH,HEIGHT-2, CUSTOMSCREEN };
struct NewWindow AboutWindow =
{ 57,55, 200,120, 2,2,
VANILLAKEY | MOUSEBUTTONS, NOCAREREFRESH | RMBTRAP | ACTIVATE | BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
200,120,200,120, CUSTOMSCREEN };
struct IntuiText MenuText[] =
{ { 2,4, JAM2, 3,1, NULL, AboutStr, NULL },
{ 2,4, JAM2, 3,1, NULL, QuitStr, NULL },
{ 2,4, JAM2, 3,1, NULL, NewGameStr, NULL },
{ 2,4, JAM2, 3,1, NULL, UndoMoveStr, NULL },
{ 2,4, JAM2, 3,1, NULL, UndoAllStr, NULL },
{ 2,4, JAM2, 3,1, NULL, LoadDragonStr, NULL },
{ 2,4, JAM2, 3,1, NULL, SaveDragonStr, NULL },
{ 2,4, JAM2, 13,1, NULL, PlayMusicStr, NULL } };
#define IFLAGS1 (HIGHCOMP | ITEMENABLED | COMMSEQ | ITEMTEXT)
#define IFLAGS2 (CHECKED | IFLAGS1 | MENUTOGGLE | CHECKIT)
struct MenuItem MenuItems[] =
{ { &MenuItems[1], 2, 2, 80,11, IFLAGS1, NULL, &MenuText[0], NULL, 'a', NULL, 0 },
{ NULL, 2,14, 80,11, IFLAGS1, NULL, &MenuText[1], NULL, 'q', NULL, 0 },
{ &MenuItems[3], 2, 2,150,11, IFLAGS1, NULL, &MenuText[2], NULL, 'n', NULL, 0 },
{ &MenuItems[4], 2,14,150,11, IFLAGS1, NULL, &MenuText[3], NULL, 'b', NULL, 0 },
{ &MenuItems[5], 2,26,150,11, IFLAGS1, NULL, &MenuText[4], NULL, 'g', NULL, 0 },
{ &MenuItems[6], 2,38,150,11, IFLAGS1, NULL, &MenuText[5], NULL, 'l', NULL, 0 },
{ &MenuItems[7], 2,50,150,11, IFLAGS1, NULL, &MenuText[6], NULL, 's', NULL, 0 },
{ NULL , 2,62,150,11, IFLAGS2, NULL, &MenuText[7], NULL, 'm', NULL, 0 } };
struct Menu MenuStrip[] =
{ { &MenuStrip[1], 2,2, 60,10, MENUENABLED, ProjectStr, &MenuItems[0], 0,0,0,0 },
{ NULL, 70,2, 60,10, MENUENABLED, OptionsStr, &MenuItems[2], 0,0,0,0 } };
WORD Coords[] =
{ 0,0, 28,0, 28,33, 0,33, 0,0 };
struct Border Border[] =
{ { 2,84, 1,2, JAM2, 5, &Coords[0], &Border[1] },
{ 290,84, 1,2, JAM2, 5, &Coords[0], NULL } };
struct IntuiText MoveIText =
{ 2,5, JAM2, 283,53, NULL, BlankStr, NULL };
UBYTE PosTable[] =
{ 0xFF,0x8F,0x1F,0xFE,0xE7,0x7F,0xF8,0xF1,0xFF,
0xFC,0x03,0x0F,0xF8,0x81,0x1F,0xF0,0xC0,0x3F,
0x60,0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x06,
0x00,0x00,0x00,0xF0,0x00,0x0F,0x00,0x00,0x00 };
ULONG BackGroundTab[] =
{ 0,0,160,0,0,99,160,99 };
ULONG APenTab[] =
{ 0,5,0,2 };
UBYTE ChannelMap[4] =
{ 3,5,10,12 };
extern struct Image Images[];
/* variables */
struct Screen *ScrPtr;
struct Window *WinPtr;
APTR SampleBuf;
LONG PiecePos1,PiecePos2;
ULONG RandVal,PieceCount;
ULONG TwoSelected,OnePiece;
BYTE Music,EndAll,AudioOpen;
struct MsgPort AudioPort;
struct IOAudio AudioIO;
struct RastPort RastPort;
struct BitMap BitMap;
UBYTE EntryTable[MAXCOUNT];
struct Dragon NewDragon;
/* arp filerequest structure */
struct FileReq
{
APTR fr_Hail;
APTR fr_File;
APTR fr_Dir;
APTR fr_Window;
UBYTE fr_Flags;
UBYTE fr_res1;
APTR fr_Func;
LONG fr_res2;
};
/* cc3 request definition */
struct ChinaReq
{
struct FileReq FReq;
UWORD Pad;
UBYTE DirBuf[256];
UBYTE FileBuf[128];
};
/* arp inlines */
static __inline ULONG
FileRequest (struct Library *ArpBase,struct FileReq *req)
{
register ULONG _res __asm("d0");
register struct Library *a6 __asm("a6") = ArpBase;
register struct FileReq *a0 __asm("a0") = req;
__asm __volatile ("jsr a6@(-294)"
: "=r" (_res)
: "r" (a6), "r" (a0)
: "a0","a1","d0","d1", "memory");
return _res;
}
static __inline VOID
TackOn (struct Library *ArpBase,UBYTE *dir, UBYTE *file)
{
register struct Library *a6 __asm("a6") = ArpBase;
register UBYTE *a0 __asm("a0") = dir;
register UBYTE *a1 __asm("a1") = file;
__asm __volatile ("jsr a6@(-624)"
: /* no output */
: "r" (a6), "r" (a0), "r" (a1)
: "a0","a1","d0","d1", "memory");
}
static __inline BPTR
ArpOpen (struct Library *ArpBase,UBYTE *name,LONG accessMode)
{
register BPTR _res __asm("d0");
register struct Library *a6 __asm("a6") = ArpBase;
register UBYTE *d1 __asm("d1") = name;
register LONG d2 __asm("d2") = accessMode;
__asm __volatile ("jsr a6@(-0x1e)"
: "=r" (_res)
: "r" (a6), "r" (d1), "r" (d2)
: "a0","a1","d0","d1","d2", "memory");
return _res;
}
/*
** NewList() as macro
*/
#define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \
(l)->lh_TailPred = (struct Node *)&(l)->lh_Head)
#endif /* _CC3_H */
/************************************************************************
* *
* end of Header File for China Challenge III - the C Version *
* *
*************************************************************************/